package com.shop.web.servlet;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.shop.domain.Order;
import com.shop.domain.User;
import com.shop.service.OrderService;

public class ListOrderServlet extends HttpServlet {
	private static final long serialVersionUID = -4747463075456052056L;
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		User user = (User) req.getSession().getAttribute("loginUser");
		List<Order> orders = new OrderService().findOrders(user);
		req.setAttribute("orders", orders);
		req.getRequestDispatcher("/list_order.jsp").forward(req, resp);
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
